package com.yuchen.ishop.service.buyer;

import com.yuchen.core.MyPager;
import com.yuchen.ishop.entity.Buyer;

import com.yuchen.ishop.entity.Shop;
import com.yuchen.jaxrs.restclient.RestClientUtils;
import com.yuchen.jaxrs.Responses;
import com.yuchen.utils.config.ConfigUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;


import java.util.HashMap;
import java.util.Map;

/**
 *
 */
@Service
public class BuyerRestClient {

    private final static Logger LOG = Logger.getLogger(BuyerRestClient.class);

    public Buyer getById(Long id) {
        String url = ConfigUtils.config.get("buyer_getById");
        Map map = new HashMap(1);
        map.put("id", id);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Buyer.class, url);
    }

    public Buyer insert(Buyer buyer) {
        String url = ConfigUtils.config.get("buyer_insert");
        return RestClientUtils.post(Buyer.class, buyer, url);
    }

    public Responses update(Buyer buyer) {
        String url = ConfigUtils.config.get("buyer_update");
        return RestClientUtils.post(Responses.class, buyer, url);
    }

    public Responses goodsTrace(Long buyerId,Long goodsId){
        String url = ConfigUtils.config.get("buyer_goodsTrace");
        Map map = new HashMap(2);
        map.put("buyerId", buyerId);
        map.put("goodsId", goodsId);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Responses.class, url);
    }

    public Responses updatePwd(Map map) {
        String url = ConfigUtils.config.get("buyer_updatePwd");
        return RestClientUtils.post(Responses.class, map, url);
    }
   
}